/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.insa.glaizot;


import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;

/**
 *
 * @author 4glaitan
 */
public class ListeNomsCombo extends JComboBox {

    public ListeNomsCombo() {
    }

    public void init() {
        if (TestSGBD.defautCon != null) {
            try {
                PreparedStatement Stat = (PreparedStatement) TestSGBD.defautCon.prepareStatement("SELECT DISTINCT NOM FROM EMPLOYE ");
                ResultSet result = Stat.executeQuery();
                while (result.next()) {
                    String nom = result.getString("NOM");
                    this.addItem(nom);
                }
            } catch (SQLException ex) {
                JOptionPane.showMessageDialog(this, "Problème  -_-'  " + ex);
            }
        }
    }
}
